/************************************************************************
 * AIDE/Examples - Automata Identification Engine
 * Copyright (C) 2012-2013 Ali Khalili (khalili_DOT_ir_@SIGN_gmail_DOT_com)
 * **********************************************************************
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License (LGPL) published 
 * by the Free Software Foundation; either version 2.1 of the License, or (at your
 * option) any later version. This program is distributed without any
 * warranty. See the GNU Lesser General Public License for more details. 
 * ***********************************************************************
 * File         :     
 * Description  :     
 * Change log   :     	-Date:  Change
 ************************************************************************/

﻿//#define USE_GLEE_VISUALISATION
using System;
using System.Collections.Generic;

using SMLib.Automata.MM;
using SMLib.Automata.Base;
using AIDE.Base;
using AIDE.OnlineAlgo.NFMs;
using AIDE.Oracles.NFMs;

namespace LearningApp.Examples
{
    /// <summary>
    /// Learn the counter example
    /// </summary>
    class LearnCounter
    {
        public static void RunExample()
        {
            //* 1- make the black box
            Examples.Counter counter = new Examples.Counter();
            //* 2- Use the real oracle
            Oracle_MAT_Realistic oracle = new Oracle_MAT_Realistic(counter);
            //* 3- Create a Mealy learner (here, we use L_Plus_M learner, e.g.)
            L_Plus_M learner = new L_Plus_M(oracle);
            //* 4-call the learn function
            MealyMachine m = learner.Learn();
#if USE_GLEE_VISUALISATION
            //* 5-Visualize the learnt machine
            Visualization.SSViewer<MealyMachine.Mealy_State, MealyMachine.Mealy_Transition> viewe =
                new Visualization.SSViewer<MealyMachine.Mealy_State, MealyMachine.Mealy_Transition>(m);
            viewe.ShowDialog();
#endif
            //* 6-Export the model into DOT file
            SMLib.Interoperability.DOT.DotHelper_MM.WriteToDot("counter5.dot", m);

            Console.WriteLine("The learnt model is exported as: counter5.dot");
        }
    }
}
